package edu.ustb.eureka.contract;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

import edu.ustb.sc.definitions.ContractActionInfo;
import edu.ustb.sc.definitions.ContractTemplate;
import edu.ustb.sc.definitions.SpescConditionCheckStatus;
import edu.ustb.sc.definitions.SpescContractTerm;

public class DiscoveryContract extends ContractTemplate {

	// 服务消费方与注册中心订立的合约
	public DiscoveryContract() {
		parties = new LinkedList<>();
		parties.add(new DiscoveryContractParty("Customer"));
		parties.add(new DiscoveryContractParty("EUREKA"));

		canTermNames = new ArrayList<>();
		mustTermNames = new ArrayList<>();
		cannotTermNames = new ArrayList<>();
		canTermNames.add("term_1");
		mustTermNames.add("term_2");

		termName2Action = new HashMap<>();
		termName2Action.put("term_1", "request");
		termName2Action.put("term_2", "discover");

		didMap = new HashMap<>();
	}

	@Override
	public String getAvailableActions(String partyId) {
		return null;
	}

	@Override
	public ContractActionInfo getUrgentMustTermAction() {
		return null;
	}

	@Override
	protected SpescContractTerm termNameMatchObj(String termName) {
		if (termName.equals("term_1")) {
			return new DiscoveryContractTerm1();
		} else if (termName.equals("term_2")) {
			return new DiscoveryContractTerm2();
		}
		return null;
	}

	// For testing term1 only
	public boolean request() {return true;}
	// For testing term2 only
	public boolean discover() {return true;}
}
